<?php
$adminAccount= $_POST['admin_account'];
$adminPassword = $_POST['admin_password'];

$dsn = "sqlsrv:Server=localhost;Database=Task";
$db = new PDO($dsn, "sa", "123456");

$sql = "SELECT * FROM Admin where AdminAccount='".$adminAccount."'";
$result = $db->query($sql);
$adminInfo = $result->fetch(PDO::FETCH_ASSOC);
if ($adminInfo && $adminInfo['AdminPassword'] == $adminPassword) {
    // 登录成功后，设置相应的登录信息
    setcookie("AdminId", $adminInfo['AdminId']);
    setcookie("AdminAccount", $adminInfo['AdminAccount']);
    echo "登录成功<br />";
    echo "<a href='task_list.php'>列表页面</a>";
    exit();
} else {
    echo "登录失败，账号或者密码不对";
    exit();
}
